package com.bdan.t382;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;

@Component
public class Printer {
    // inkCartridge 和 paper 是 Printer 类的成员变量
    private InkCartridge inkCartridge;
    private Paper paper;

    @Autowired
    public Printer(
            @Qualifier("colorInk") InkCartridge inkCartridge,
            @Qualifier("a4Paper") Paper paper
    ) {
        this.inkCartridge = inkCartridge;
        this.paper = paper;
    }


    public void print(String text) {
        System.out.println("使用 " + paper.getSize() + " paper:");
        inkCartridge.print(text);
    }
}
